Fix plan implementation prompt reappearing after /agent thread switch#10447
Fix plan implementation prompt reappearing after /agent thread switch#10447charley-oai merged 2 commits intomainfrom
Conversation
|
@codex review this |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e241a04023
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review this |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
This fixes a UX bug (#10442) where the "Implement this plan?" prompt could reappear after switching agents with
/agentand then switching back to the original agent during plan execution.Root Cause
On thread switch, the TUI rebuilds
ChatWidget, replays buffered thread events, then drains any queued live events.In this flow, a
TurnCompletecan be handled twice for the same logical turn:from_replay = true)from_replay = false)ChatWidgetusedsaw_plan_item_this_turnto decide whether to show the plan implementation prompt, but that flag was only reset onTurnStarted.If duplicate completion events occurred, stale
saw_plan_item_this_turn = truecould cause the prompt to re-trigger unexpectedly.Fix
saw_plan_item_this_turnat the end ofon_task_complete, after prompt gating runs.TurnCompletehandling from reopening the prompt.